package ge.lowlevel;

import java.util.Date;
import java.util.HashMap;

import ge.exceptions.FunctionNonSuported;
import ge.modules.utils.FileModule;
import ge.modules.utils.IWebCallModule;


/**
 * 
 * @author Abel
 * Utility Engine has all the functions of the Engine who should be separated for 
 * garantee the Engine poratbility
 */
public class UtilityEngine 
{
	protected static UtilityEngine delegated;
	private static int callBackId = 0;
	
	public static int getCallbackId()
	{
		
		return callBackId++;
	}
	public UtilityEngine()
	{
		
	}
	/**
	 * 	Sets the concrete engine
	 * @param engine
	 */
	static public  void set(UtilityEngine engine)
	{
		delegated = engine;
	}
	/**
	 * 	
	 * @return gets the concrete UtilityEngine
	 */
	static public UtilityEngine get()
	{
		return delegated;
	}
	
	/**
	 * 	Sets a interval for a Interval object
	 * @param time	Time in miliseconds
	 * @param object	Object Interval to be repeated
	 * @param loop	If the interval has to be repeated
	 * @throws FunctionNonSuported	if the engine doesn't support it
	 */
	public void setInterval(int time, Interval object,boolean loop) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("Utility Engine","setInterval");
	}
	/**
	 * 	Stops the Interval object
	 * @param object	Is the interval object.
	 * @throws FunctionNonSuported if the engine doesn't support it
	 */
	public void cancelInterval(Interval object) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("Utility Engine","cancelInterval");
	}
	/**
	 * 	
	 * @param file FileModule
	 * @return The content of the file
	 * @throws FunctionNonSuported  if the engine doesn't support it
	 */
	public String readFile(FileModule file) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("utility Engine", "readFile");
	}
	/**
	 * 
	 * @param web Module who has the information necessary to be sent (Url, and request data)
	 * @throws FunctionNonSuported if the engine doesn't support it
	 */
	public void callPostUrl(IWebCallModule web) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("Utility Engine","callPostUrl");
	}
	/**
	 * 
	 * @param params Hasmap where the key is the name of the param, and the value its value
	 * @return String with the url format and prepared to be URL friendly
	 * @throws FunctionNonSuported if the engine doesn't support it
	 */
	public String formatRequestParams(HashMap<String, String> params) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("Utility Engine","formatRequestParams");	
	}
	
	/**
	 * 	Makes a call to a remote server using a proxy and avoiding the security web restriction
	 * 	You need a parameter named "callback" with value "callback"+"UtilityEngine.getRemoteID()"
	 * @param requestId	Identify the call
	 * @param handler	Element who handles the response
	 * @throws FunctionNonSuported If the engine doesn't support it.
	 */
	public void remoteCall(int requestId, IWebCallModule handler) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("Utility Engine","remoteCall");
	}
	/**
	 * 	Parses a string in this format
	 * @param format
	 * @param date 
	 * @return A object date
	 * @throws FunctionNonSuported If the engine doesn't support it.
	 */
	public Date stringToDate(String format,String date) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("Utility Engine","stringToDate");
	}
	/**
	 * 	Executes a script in the browser
	 * @param source_url Source of script
	 * @throws FunctionNonSuported  If the engine doesn't support it.
	 */
	public void execute_script(String source_url) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("Utility Engine","execute_script");
	}
	/**
	 * 	Evals directly a script code
	 * @param script Code to eval
	 * @throws FunctionNonSuported If the engine doesn't support it.
	 */
	public void eval_script(String script) throws FunctionNonSuported
	{
		throw new FunctionNonSuported("Utility Engine","eval_script");
	}
	
}
